package com.jkc.xh.network;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import retrofit.GsonConverterFactory;
import retrofit.Retrofit;

/**
 * Created by 洁 on 2015/9/16.
 */
public class ApiClient {

    //服务器地址
//    public static final String BASE_URL = "http://dev.jkjy88.com/";
//    public static String BASE_URL = "http://a.yhc8168.cn";
    public static String BASE_URL = "https://xhapp.yhc8168.cn";
    private com.jkc.xh.network.ApiService apiService;

    private ApiClient() {
        Gson gson = new GsonBuilder()
//                .registerTypeAdapterFactory(new ItemTypeAdapterFactory())
                .create();
        //增加header
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .client(com.jkc.xh.network.ApiOkHttpClient.getClient())
                .addConverterFactory(GsonConverterFactory.create(gson))
                .build();
        apiService = retrofit.create(com.jkc.xh.network.ApiService.class);
    }


    public static com.jkc.xh.network.ApiService getApiService() {

        return ApiClientHolder.INSTANCE.apiService;
    }


    private static class ApiClientHolder {
        public static ApiClient INSTANCE = new ApiClient();
    }
}
